package com.landi.carkey.util;

/**
 * Created by Administrator on 2016/12/30.
 */

import java.io.File;

public class FileUtil {
    public static File updateDir;
    public static File updateFile;

    public static boolean createFile(String url, String name) {
        // 判断SD卡可读可写
        if (android.os.Environment.MEDIA_MOUNTED.equals(android.os.Environment
                .getExternalStorageState())) {
            updateDir = new File(url + File.separator);
            updateFile = new File(url + File.separator + name + ".apk");
            if (!updateDir.exists()) {
                updateDir.mkdirs();
            }
            if (!updateFile.exists()) {
                try {
                    updateFile.createNewFile();
                } catch (Exception e) {
                    e.printStackTrace();
                    return false;
                }
            }
            return true;
        }
        return false;
    }

    public static void delFile(String path) {
        File file = new File(path);
        if (file.exists()) {
            file.delete();
        }
    }
}